﻿<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:lz="http://schemas.icitadel.com/Lazarus/Source.xsd" attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://schemas.icitadel.com/Lazarus/Source.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:simpleType name="ObjectTypes">
    <xs:restriction base="xs:string">
      <xs:enumeration value="Default" />
      <xs:enumeration value="Intersection" />
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="IndexTypes">
		<xs:restriction base="xs:string">
			<xs:enumeration value="Foreign" />
			<xs:enumeration value="Unique" />
			<xs:enumeration value="Primary" />
			<xs:enumeration value="Clustered" />
		</xs:restriction>
	</xs:simpleType>
	<xs:simpleType name="ConstraintModifiers">
		<xs:restriction base="xs:string">
			<xs:enumeration value="Default" />
			<xs:enumeration value="Not" />
		</xs:restriction>
	</xs:simpleType>
	<xs:simpleType name="ConstraintOperations">
		<xs:restriction base="xs:string">
			<xs:enumeration value="GreaterThan" />
			<xs:enumeration value="GreaterThanOrEqual" />
			<xs:enumeration value="LessThan" />
			<xs:enumeration value="LessThanOrEqual" />
			<xs:enumeration value="ExclusiveBetween" />
			<xs:enumeration value="InclusiveBetween" />
			<xs:enumeration value="Equal" />
			<xs:enumeration value="In" />
		</xs:restriction>
	</xs:simpleType>
	<xs:simpleType name="MethodTypes">
		<xs:restriction base="xs:string">
			<xs:enumeration value="Create" />
			<xs:enumeration value="Update" />
			<xs:enumeration value="Get" />
			<xs:enumeration value="List" />
			<xs:enumeration value="Custom" />
		</xs:restriction>
	</xs:simpleType>
	<xs:simpleType name="ImplementDBMethods">
		<xs:restriction base="xs:string">
			<xs:enumeration value="Category" />
			<xs:enumeration value="Aggregate" />
		</xs:restriction>
	</xs:simpleType>
	<xs:simpleType name="ParameterDirections">
		<xs:restriction base="xs:string">
			<xs:enumeration value="in" />
			<xs:enumeration value="out" />
		</xs:restriction>
	</xs:simpleType>
	<xs:simpleType name="FieldTypes">
		<xs:restriction base="xs:string">
			<xs:enumeration value="Char" />
			<xs:enumeration value="Varchar" />
			<xs:enumeration value="Uniqueidentifier" />
			<xs:enumeration value="Bit" />
			<xs:enumeration value="Int" />
			<xs:enumeration value="TinyInt" />
			<xs:enumeration value="Text" />
			<xs:enumeration value="DateTime" />
			<xs:enumeration value="Identity" />
			<xs:enumeration value="Decimal" />
			<xs:enumeration value="Money" />
			<xs:enumeration value="Float" />
		</xs:restriction>
	</xs:simpleType>
	<xs:simpleType name="UserTypes">
		<xs:restriction base="xs:string">
			<xs:enumeration value="Internal" />
			<xs:enumeration value="Windows" />
		</xs:restriction>
	</xs:simpleType>
	<xs:simpleType name="Description">
		<xs:restriction base="xs:string" />
	</xs:simpleType>
	<xs:element name="project">
		<xs:complexType>
			<xs:sequence>
				<xs:element name="description" type="xs:string" />
				<xs:element name="datasource">
					<xs:complexType>
						<xs:attribute name="location" type="xs:string" use="required" />
						<xs:attribute name="schema" type="xs:string" use="required" />
						<xs:attribute name="user" type="xs:string" use="optional" />
						<xs:attribute name="password" type="xs:string" use="optional" />
					</xs:complexType>
				</xs:element>
				<xs:element name="defaults">
					<xs:complexType>
						<xs:sequence>
							<xs:element name="fields">
								<xs:complexType>
									<xs:sequence>
                    <xs:element maxOccurs="unbounded" name="field">
                      <xs:complexType>
                        <xs:sequence minOccurs="0">
                          <xs:element minOccurs="0" name="description" type="xs:string" />
                          <xs:element minOccurs="0" name="indexes">
                            <xs:complexType>
                              <xs:sequence>
                                <xs:element maxOccurs="unbounded" name="index">
                                  <xs:complexType>
                                    <xs:attribute name="type" type="lz:IndexTypes" use="required" />
                                    <xs:attribute name="object" type="xs:string" use="optional" />
                                  </xs:complexType>
                                </xs:element>
                              </xs:sequence>
                            </xs:complexType>
                          </xs:element>
                        </xs:sequence>
                        <xs:attribute name="name" type="xs:string" use="required" />
                        <xs:attribute name="type" type="lz:FieldTypes" use="optional" />
                        <xs:attribute name="size" type="xs:unsignedByte" use="optional" />
                        <xs:attribute name="required" type="xs:boolean" use="optional" />
                        <xs:attribute name="readonly" type="xs:boolean" use="optional" />
                        <xs:attribute name="autogenerate" type="xs:boolean" use="optional" />
                        <xs:attribute name="default" type="xs:unsignedByte" use="optional" />
                      </xs:complexType>
                    </xs:element>
                  </xs:sequence>
								</xs:complexType>
							</xs:element>
						</xs:sequence>
					</xs:complexType>
				</xs:element>
				<xs:element name="objects">
					<xs:complexType>
						<xs:sequence>
							<xs:element maxOccurs="unbounded" name="object">
								<xs:complexType>
									<xs:sequence>
										<xs:element minOccurs="0" name="description" type="xs:string" />
										<xs:element name="fields">
											<xs:complexType>
												<xs:sequence>
													<xs:element maxOccurs="unbounded" name="field">
														<xs:complexType>
															<xs:sequence minOccurs="0">
																<xs:element minOccurs="0" name="description" type="xs:string" />
																<xs:element minOccurs="0" name="indexes">
																	<xs:complexType>
																		<xs:sequence>
																			<xs:element maxOccurs="unbounded" name="index">
																				<xs:complexType>
																					<xs:attribute name="type" type="lz:IndexTypes" use="required" />
																					<xs:attribute name="object" type="xs:string" use="optional" />
																				</xs:complexType>
																			</xs:element>
																		</xs:sequence>
																	</xs:complexType>
																</xs:element>
															</xs:sequence>
															<xs:attribute name="name" type="xs:string" use="required" />
															<xs:attribute name="type" type="lz:FieldTypes" use="optional" />
															<xs:attribute name="size" type="xs:unsignedByte" use="optional" />
															<xs:attribute name="required" type="xs:boolean" use="optional" />
                              <xs:attribute name="readonly" type="xs:boolean" use="optional" />
                              <xs:attribute name="autogenerate" type="xs:boolean" use="optional" />
                              <xs:attribute name="default" type="xs:unsignedByte" use="optional" />
														</xs:complexType>
													</xs:element>
												</xs:sequence>
											</xs:complexType>
										</xs:element>
										<xs:element minOccurs="0" name="collections">
											<xs:complexType>
												<xs:sequence>
													<xs:element maxOccurs="unbounded" name="collection">
														<xs:complexType>
															<xs:attribute name="name" type="xs:string" use="required" />
															<xs:attribute name="object" type="xs:string" use="required" />
															<xs:attribute name="binding-object" type="xs:string" use="optional" />
															<xs:attribute name="binding-field" type="xs:string" use="required" />
														</xs:complexType>
													</xs:element>
												</xs:sequence>
											</xs:complexType>
										</xs:element>
										<xs:element minOccurs="0" name="methods">
											<xs:complexType>
												<xs:sequence>
													<xs:element maxOccurs="unbounded" name="method">
														<xs:complexType>
															<xs:sequence minOccurs="0">
																<xs:element minOccurs="0" maxOccurs="1" name="description" type="xs:string" />
																<xs:element minOccurs="0" maxOccurs="1" name="method-filters">
																	<xs:complexType>
																		<xs:sequence>
																			<xs:element name="method-filter">
																				<xs:complexType>
																					<xs:attribute name="field" type="xs:string" use="required" />
																					<xs:attribute name="value" type="xs:string" use="optional" />
																				</xs:complexType>
																			</xs:element>
																		</xs:sequence>
																	</xs:complexType>
																</xs:element>
																<xs:element minOccurs="0" maxOccurs="1" name="method-params">
																	<xs:complexType>
																		<xs:sequence>
																			<xs:element name="method-param">
																				<xs:complexType>
																					<xs:attribute name="name" type="xs:string" use="required" />
																					<xs:attribute name="type" type="lz:FieldTypes" use="required" />
																					<xs:attribute name="required" type="xs:boolean" use="optional" default="false" />
																				</xs:complexType>
																			</xs:element>
																		</xs:sequence>
																	</xs:complexType>
																</xs:element>
																<xs:element minOccurs="0" maxOccurs="1" name="affected-fields">
																	<xs:complexType>
																		<xs:sequence>
																			<xs:element name="field">
																				<xs:complexType>
																					<xs:attribute name="name" type="xs:string" use="required" />
																				</xs:complexType>
																			</xs:element>
																		</xs:sequence>
																	</xs:complexType>
																</xs:element>
															</xs:sequence>
															<xs:attribute name="type" type="lz:MethodTypes" use="required" />
															<xs:attribute name="name" type="xs:string" use="optional" />
															<xs:attribute name="db-name" type="xs:string" use="optional" />
														</xs:complexType>
													</xs:element>
												</xs:sequence>
											</xs:complexType>
										</xs:element>
									</xs:sequence>
									<xs:attribute name="name" type="xs:string" use="required" />
									<xs:attribute name="title-field" type="xs:string" use="optional" />
									<xs:attribute name="friendly-name" type="xs:string" use="optional" />
                  <xs:attribute name="plural-name" type="xs:string" use="optional" />
                  <xs:attribute name="type" type="lz:ObjectTypes" use="optional" />
								</xs:complexType>
							</xs:element>
						</xs:sequence>
					</xs:complexType>
				</xs:element>
			</xs:sequence>
			<xs:attribute name="name" type="xs:string" use="required" />
			<xs:attribute name="namespace" type="xs:string" use="required" />
			<xs:attribute name="owner" type="xs:string" use="required" />
			<xs:attribute name="user" type="xs:string" use="required" />
			<xs:attribute name="namespaceprefix" type="xs:string" use="required" />
			<xs:attribute name="namespaceuri" type="xs:string" use="required" />
		</xs:complexType>
	</xs:element>
</xs:schema>